﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
using System.Runtime.Serialization;

namespace CommonUtil
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class Args
    {
        private string connectionString;
        /// <summary>
        /// 数据库连接字符串
        /// </summary>
        public string ConnectionString
        {
            get { return connectionString; }
            set { connectionString = value; }
        }
        [NonSerialized]
        private System.Data.SqlClient.SqlConnection databaseConnection;
        /// <summary>
        /// 数据库连接对象
        /// </summary>        
        public System.Data.SqlClient.SqlConnection DatabaseConnection
        {
            get { return databaseConnection; }
            set { databaseConnection = value; }
        }
        private System.Data.DataTable engChsValueList;
        /// <summary>
        /// 中英文对照表
        /// </summary>
        public System.Data.DataTable EngChsValueList
        {
            get { return engChsValueList; }
            set { engChsValueList = value; }
        }
        private string loginID;   //登录ID（员工内码）
        /// <summary>
        /// 登录ID
        /// </summary>
        public string LoginID
        {
            get { return loginID; }
            set { loginID = value; }
        }
        private string loginNum;   //工号
        /// <summary>
        /// 登录工号
        /// </summary>
        public string LoginNum
        {
            get { return loginNum; }
            set { loginNum = value; }
        }
        private string loginName; //姓名
        /// <summary>
        /// 登录姓名
        /// </summary>
        public string LoginName
        {
            get { return loginName; }
            set { loginName = value; }
        }
        private string userName; //姓名
        /// <summary>
        /// 用户姓名
        /// </summary>
        public string UserName
        {
            get { return userName; }
            set { userName = value; }
        }
        private System.Data.DataTable menuDataTable;
        /// <summary>
        /// 菜单DataTable
        /// </summary>
        public System.Data.DataTable MenuDataTable
        {
            get { return menuDataTable; }
            set { menuDataTable = value; }
        }
        private System.Data.DataTable mainMenuDataTable;
        /// <summary>
        /// 主菜单DataTable
        /// </summary>
        public System.Data.DataTable MainMenuDataTable
        {
            get { return mainMenuDataTable; }
            set { mainMenuDataTable = value; }
        }
        private System.Data.DataTable subMenuDataTable;
        /// <summary>
        /// 子菜单DataTable
        /// </summary>
        public System.Data.DataTable SubMenuDataTable
        {
            get { return subMenuDataTable; }
            set { subMenuDataTable = value; }
        }
        private System.Data.DataTable nodeMenuDataTable;
        /// <summary>
        /// 节点菜单DataTable
        /// </summary>
        public System.Data.DataTable NodeMenuDataTable
        {
            get { return nodeMenuDataTable; }
            set { nodeMenuDataTable = value; }
        }
        [NonSerialized]
        private TabControl currentTabControl;
        /// <summary>
        /// 当前TabControl
        /// </summary>
        public TabControl CurrentTabControl
        {
            get { return currentTabControl; }
            set { currentTabControl = value; }
        }
        [NonSerialized]
        private TabPage currentTabPage;
        /// <summary>
        /// 当前TabPage
        /// </summary>
        public TabPage CurrentTabPage
        {
            get { return currentTabPage; }
            set { currentTabPage = value; }
        }

        private System.Data.DataTable specialRightDt;
        /// <summary>
        /// 特殊权限DataTable
        /// </summary>
        public System.Data.DataTable SpecialRightDt
        {
            get { return specialRightDt; }
            set { specialRightDt = value; }
        }
        [NonSerialized]
        private PaletteMode mainPaletteMode;
        /// <summary>
        /// Krypton样式
        /// </summary>
        public PaletteMode MainPaletteMode
        {
            get { return mainPaletteMode; }
            set { mainPaletteMode = value; }
        }

        /// <summary>
        /// 关闭当前TabPage
        /// </summary>
        public void CloseTabPage()
        {
            try
            {
                if (currentTabControl != null && currentTabPage != null)
                {
                    if (currentTabControl.TabPages.IndexOf(currentTabPage) != 0)
                    {
                        currentTabControl.TabPages.Remove(currentTabPage);
                    }
                    GC.WaitForPendingFinalizers();
                    GC.Collect();
                }
            }
            catch (Exception ex)
            {
                Logger.DefaultLog("Args关闭当前TabPage异常：" + ex.StackTrace, LogType.Error);
            }
        }
    }
}
